﻿
using System;
using System.Threading;
using System.Threading.Tasks;

namespace WSU.ChekaParallel.TestThread
{
    static class TestLazy
    {
        private static void TestRunLazyTask()
        {
            Func<string> taskbody = () =>
                {
                    Console.WriteLine("task running, ......");
                    Thread.Sleep(500);
                    return "cheka";
                };

            Lazy<Task<string>> lazyData = new Lazy<Task<string>>(() => Task.Factory.StartNew(taskbody), false);

            Console.WriteLine("Press any button to query the lazy value.");
            Console.ReadLine();

            Console.WriteLine("value from the task is: {0}", lazyData.Value.Result);
        }

        public static void TestMain()
        {
            TestRunLazyTask();
        }
    }
}